package com.zallds.window;

import com.zallds.utils.Utils;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * 滑动计数窗口
 *  乘客每测2次体温,就返回最近4次最高的体温
 */
public class SlideCountWindowDemo {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.socketTextStream("192.168.62.37",8889)
                .flatMap(new Utils.Splitter())
                .keyBy(value -> value.f0)
                .countWindow(4,2)
                .maxBy(1)
                .print();

        env.execute();

    }
}
